package com.jinlejia.bbs.ui.message;


import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jinlejia.bbs.R;
import com.jinlejia.bbs.bean.MessageCountBean;
import com.jinlejia.bbs.databinding.BbsFragmentMessageBinding;
import com.jinlejia.bbs.help.CommonEvent;
import com.jinlejia.bbs.logic.message.MessageLogic;
import com.jinlejia.bbs.ui.mine.BBSAnswerListActivity;
import com.jinlejia.bbs.ui.mine.BBSCommentListActivity;

/**
 * 消息页面
 */
public class BBSMessageFragment extends Fragment implements MessageLogic.LogicCallBack {

    private BbsFragmentMessageBinding binding;
    private View view;
    private MessageLogic logic;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (view == null) {
            view = inflater.inflate(R.layout.bbs_fragment_message, container, false);
            binding = DataBindingUtil.bind(view);
        }
        logic = new MessageLogic(this,this);
        binding.setEvent(this);
        binding.setCommonEvent(CommonEvent.obtain());
        return view;
    }

    @Override
    public void onResume() {
        super.onResume();
        logic.execute();
    }

    //跳转至 邀请回答
    public void toInviteAnswerActivity(View view) {
        Intent intent = new Intent();
        intent.setClass(getContext(), BBSInviteListActivity.class);
        startActivity(intent);
    }

    //跳转至 获赞列表
    public void toLikeListActivity(View view) {
        Intent intent = new Intent();
        intent.setClass(getContext(), BBSLikeListActivity.class);
        startActivity(intent);
    }

    //跳转至消息回答列表
    public void toAnswerListActivity(View view) {
        Intent intent = new Intent();
        intent.setClass(getContext(), BBSAnswerListActivity.class);
        startActivity(intent);
    }

    //跳转至我的评论列表
    public void toMyCommentListActivity(View view) {
        Intent intent = new Intent();
        intent.setClass(getContext(), BBSCommentListActivity.class);
        startActivity(intent);
    }


    @Override
    public void onResult(MessageCountBean bean) {
        binding.setBean(bean);
    }
}
